import React, { Component, createContext } from 'react'

const { Provider, Consumer } = createContext()


function ComB() {
    return (
        <Consumer>
            {(val) => {
                return <div>ComB --- {val}</div>
            }}
        </Consumer>
    )
}

function ComA() {
    return (
        <div>
            ComA
            <ComB></ComB>
        </div>
    )
}

export default class App extends Component {
    constructor(props) {
        super(props)
        state = {
            age: 50
        }
    }

    render() {
        return (
            <Provider value={this.state.age}>
                <div>
                    App3
                    <ComA></ComA>
                </div>
            </Provider>

        )
    }
}